﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MockupDesigner.Items;
using System.Windows;

namespace MockupDesigner.Editors.TextEditors.Lists
{
    public class MenuEditor : TextEditorBase
    {
        private MenuItem itemToEdit;

        public override void element_LostFocus(object sender, RoutedEventArgs e)
        {
            this.itemToEdit.Items = this.element.Text.Split(new string[] { "\r", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
        }

        public override void element_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            // Nothing to Do
        }

        public override void SetItem(ItemBase itemToEdit)
        {
            base.SetItem(itemToEdit);
            this.itemToEdit = itemToEdit as MenuItem;
            base.element.AcceptsReturn = true;
            base.element.Text = string.Join("\r\n", this.itemToEdit.Items);
            if (this.element.Height < 150)
            {
                this.element.Height = 150;
            }
            if (this.element.Width < 150)
            {
                this.element.Width = 150;
            }
        }
    }
}
